package com.ss.android.article.browser.database.b;

import android.database.Cursor;
import android.support.annotation.NonNull;

import com.a.a.NightMode;
import com.a.a.u;

import java.util.ArrayList;
import java.util.List;

final class HistorySearcher implements NightMode {
    private final HistoryManager historyManager;
    private final String keywords;

    HistorySearcher(HistoryManager historyManager, String keywords) {
        this.historyManager = historyManager;
        this.keywords = keywords;

    }

    public final void f(@NonNull Object arg11) {
        ArrayList arrayList = new ArrayList(5);
        String likeExpress = "%" + this.keywords + '%';
        Cursor cursor = HistoryManager.getDatabase(this.historyManager)
                .query("history", null,
                        "title LIKE ? OR url LIKE ?",
                        new String[]{likeExpress, likeExpress},
                        null,
                        null,
                        "time DESC",
                        "5");
        while (cursor.moveToNext()) {
            arrayList.add(HistoryManager.parseBrowserHistory(cursor));
        }

        cursor.close();
        ((u) arg11).onItem(arrayList);
        ((u) arg11).onComplete();
    }
}

